/*
 * IAnimationController.h
 *
 *  Created on: 05.01.2012
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#ifndef IANIMATIONCONTROLLER_H_
#define IANIMATIONCONTROLLER_H_

#include "IAnimationState.h"
#include "IAnimationInterface.h"
#include "IPhysicsObject.h"
#include "../BasicTypes.h"

class CAnimationController
{
friend class AnimationFabric;
private:
	CAnimationController( std::vector<CBasicAnimation> &AnimationArray, IPhysicsObject* PhysicsObject );
	virtual ~CAnimationController();

	/*
	 * Replace an animation with the same name as NewAnimation have from AnimationArray
	 * return: true - if an animation with required name exists, otherwise false.
	 */
	bool ReplaceAnimation( CBasicAnimation &NewAnimation );

	/*
	 * Contains animation states, sorted in order of their names
	 */
	std::vector<CBasicAnimation> animationArray;//TODO Search can be optimized by building a tree

	IPhysicsObject              *physicsObject;

protected:

	CBasicAnimation* FindAnimationByName( std::string Name );

public:

    IAnimationInterface* GetAnimationInterfaceByName( std::string AnimationName );

    IAnimationState* GetAnimationStateByName( std::string AnimationName );

    void PlayAnimations( IAnimationPlayer* AnimationPlayer );

    glm::mat4 GetObjectWorldPosition();
};

#endif /* IANIMATIONCONTROLLER_H_ */

